
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ******* * * * * * Here is the option for GuildSlacker * * * * * *******
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

-- How long we have to wait from the achievement to we do the gratz. (Default = 10)
GS_Delay = 10;

-- How long we have to wait from one gratz to the next gratz so we don't spam. (Default = 60)
GS_Break = 60;

-- Do a gratz in guild on achievement. on / off (Default = off)
GS_GratzInGuild = "off";

-- Do a gratz in party and raid on achievement. on / off (Default = off)
GS_GratzInGroup = "off";

-- Do a welcome when a new member join the guild. on / off (Default = off)
GS_WelcomeOnNew = "off";

-- Make a raid warning to your self when a new member join the guild. on / off. (Default = off)
GS_RaidWarningOnNewInGuild = "off";

-- Do a Ding in guild chat when level. on / off. (Default = off)
GS_DingOnLevel = "off"

-- How long do we wait before we say "Ding" i guild chat ? (Default = 4)
GS_DingDelay = 4;

-- Take a picture when level gain. on / off (Default = on)
GS_PicOnLevel = "on"

-- Take a picture when we get a achievement. on / off (Default = on)
GS_PicOnAchievement = "on"

-- Do all whispers as raid warnings. on / off (Default = off)
GS_DoTheWhisper = "off"

-- The version of the addon >>> ONLY FOR THE PROJECT MANAGER <<<
GS_Version = GetAddOnMetadata("GuildSlacker","Version")

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ******************** * * * * * Option end * * * * * *******************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- *********************** * * * * * ToDo * * * * * **********************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

-- *  Fix the none gratz right after midnight - Working on it
-- *  Make sure that the addon don't respond when the event is from our self - OK
-- *  Make slash commands work - Working on it
-- *  Make logout - Not startet yet
-- *  Make random message to achievement gratz and guild join welcome - OK
-- *  Take a picture when a boss is killed - Not startet yet
-- *  Get someone to check spelling - Not startet yet
-- *  Make total played - Not startet yet
-- *  Make emote reply - Not startet yet

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ********************* * * * * * ToDo end * * * * * ********************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

-- Create a frame to use
local f = CreateFrame("Frame")

-- Register all the events we want to use
f:RegisterEvent("ADDON_LOADED") -- Fires when a addon is loaded.
f:RegisterEvent("CHAT_MSG_ACHIEVEMENT") -- Fires when a nearby character earns an achievement.
f:RegisterEvent("CHAT_MSG_GUILD_ACHIEVEMENT") -- Fires when a member of the player's guild earns an achievement.
f:RegisterEvent("CHAT_MSG_SYSTEM") -- Fires when a system message is received.
f:RegisterEvent("PLAYER_LEVEL_UP") -- Fires when the player gain a level.
-- f:RegisterEvent("CHAT_MSG_TEXT_EMOTE") -- Fires when the player receives a standard emote (e.g. `/dance`, `/flirt`) message.
-- f:RegisterEvent("PLAYER_LOGOUT") -- Fires immediately before the player is logged out of the game.
f:RegisterEvent("CHAT_MSG_WHISPER") -- Fires when someone whisper to you.
f:RegisterEvent("CHAT_MSG_BN_WHISPER") -- Fires when someone with BattleNet ID whisper to you.

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ******************* * * * * * SlashCommands * * * * * *****************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

-- Enable the use of /gsl or /guildslacker to to show options
SLASH_GUILDSLACKER1 = "/guildslacker";
SLASH_GUILDSLACKER2 = "/gsl";
-- Handle the slash commands
SlashCmdList["GUILDSLACKER"] = function(msg)
    -- Split msg
    var = {strsplit(" ", msg)} 
    -- Check to see if msg is emty
    if (msg == "") then
        print ("--- GuildSlacker Settings ---");
        print ("Change the delay from action to message:");
        print ("/GSL Delay [number]");
        print ("Time from one message to the next message so we don't spam:");
        print ("/GSL Break [number]");
        print ("Do the gratz on achievement in guild:");
        print ("/GSL GratzInGuild [On] / [Off]");
        print ("Do the gratz on achievement in group:");
        print ("/GSL GratzInGroup [On] / [Off]");
        print ("Welcome a new member to the guild:");
        print ("/GSL WelcomeOnNew [On] / [Off]");
        print ("Show a raid warning when a new member join the guild:");
        print ("/GSL RaidWarningOnNewInGuild [On] / [Off]");
        print ("Say ''DING'' in guild chat when you gain a level:");
        print ("/GSL DingOnLevel [On] / [Off]");
        print ("None of the slash commands is working yet. Sorry but im working on it...");
        print ("But you can change it all in the LUA file");
    -- ******************** Delay ********************
    -- 
    elseif (string.find(msg:lower(),"delay")) then
        -- 
        if (var[3] == nil) then
            -- 
            if (tonumber(var[2])) and (var[2] ~= nil) then
                --- Set the new variable
                -- GS_Delay = tonumber(var[2]);
                print ("Delay for message is now set to " ..var[2].. " (Default = 4)");
            -- 
            else
                print ("/GSL Delay [number]");
            end
        -- 
        else
            print ("/GSL Delay [number]");
        end
    -- ******************** Break ********************
    -- 
    elseif (string.find(msg:lower(),"break")) then
        -- 
        if (var[3] == nil) then
            -- 
            if (tonumber(var[2])) and (var[2] ~= nil) then
                --- Set the new variable
                -- GS_Break = tonumber(var[2]);
                print ("Time from one message to the next message is now set to " ..var[2].. " (Default = 4)");
            -- 
            else
                print ("/GSL Break [number]");
            end
        -- 
        else
            print ("/GSL Break [number]");
        end
    -- ******************** GratzInGuild ********************
    -- 
    elseif (string.find(msg:lower(),"gratzinguild")) then
        -- 
        if (var[3] == nil) and (var[2] ~= nil) then
            -- 
            if (var[2]:lower() == "on") or (var[2]:lower() == "off") then
                --- Set the new variable
                -- GS_GratzInGuild = var[2];
                print ("Do the gratz in guild is now set to " ..var[2].. " (Default = On)");
            -- 
            else
                print ("/GSL GratzInGuild [On] / [Off]");
            end
        -- 
        else
            print ("/GSL GratzInGuild [On] / [Off]");
        end
    -- ******************** GratzInGroup ********************
    -- 
    elseif (string.find(msg:lower(),"gratzingroup")) then
        -- 
        if (var[3] == nil) and (var[2] ~= nil) then
        
            -- 
            if (var[2]:lower() == "on") or (var[2]:lower() == "off") then
                --- Set the new variable
                -- GS_GratzInGroup = var[2];
                print ("Do the gratz in group is now set to " ..var[2].. " (Default = On)");
            -- 
            else
                print ("/GSL GratzInGroup [On] / [Off]");
            end
        -- 
        else
            print ("/GSL GratzInGroup [On] / [Off]");
        end
    -- ******************** WelcomeOnNew ********************
    -- 
    elseif (string.find(msg:lower(),"welcomeonnew")) then
        -- 
        if (var[3] == nil) and (var[2] ~= nil) then
            -- 
            if (var[2]:lower() == "on") or (var[2]:lower() == "off") then
                --- Set the new variable
                -- GS_WelcomeOnNew = var[2];
                print ("Do the welcome to new members is now set to " ..var[2].. " (Default = On)");
            -- 
            else
                print ("/GSL WelcomeOnNew [On] / [Off]");
            end
        -- 
        else
            print ("/GSL WelcomeOnNew [On] / [Off]");
        end
    -- ******************** RaidWarningOnNewInGuild ********************
    -- 
    elseif (string.find(msg:lower(),"raidwarningonnewinguild")) then
        -- 
        if (var[3] == nil) and (var[2] ~= nil) then
            -- 
            if (var[2]:lower() == "on") or (var[2]:lower() == "off") then
                --- Set the new variable
                -- GS_RaidWarningOnNewInGuild = var[2];
                print ("Show raid warning on new member in guild is now set to " ..var[2].. " (Default = On)");
            -- 
            else
                print ("/GSL RaidWarningOnNewInGuild [On] / [Off]");
            end
        -- 
        else
            print ("/GSL RaidWarningOnNewInGuild [On] / [Off]");
        end
    -- ******************** ********************
    -- ******************** ********************
    --[[
    elseif (string.find(msg:lower(),"gratz")) then
        --
        if (tonumber[var2]) and (var[3] ~= nil) then
            -- 
            nouse, number, message = strsplit(" ", msg, 3)
            -- 
            print (nouse);
            print (number);
            print (message);
            if (tonumber(number) == 1) then
                GS_Gratz1 = message
            elseif (tonumber(number) == 2) then
                GS_Gratz2 = message
            elseif (tonumber(number) == 3) then
                GS_Gratz3 = message
            elseif (tonumber(number) == 4) then
                GS_Gratz4 = message
            elseif (tonumber(number) == 5) then
                GS_Gratz5 = message
            elseif (tonumber(number) == 6) then
                GS_Gratz6 = message
            else
                print ("Unknown error...");
            end
        -- 
        else
            print (/GSL Gratz [1 to 6] [message]);
        end
    end

|cff66ccffOn|r









    elseif (var[3] == nil) then
        -- ******************** ********************
        -- Is the word "delay" in the string ?
        if (string.find(msg:lower(),"delay")) then
            -- Is the 2 word a number ?
            if (tonumber(var[2])) and (var[2] ~= nil) then
                -- Set the new variable
                -- GS_Delay = tonumber(var[2]);
                print ("Delay for message is now set to " ..var[2].. " (Default = 4)");
            else
                print ("/gsl delay [number]");
            end
        -- 
        end--elseif
    -- Check that there at least is 2 words
    elseif (var[2] ~= nil) then
        -- ******************** ********************
        -- Is gratzinguild in the string ?
        if (string.find(msg:lower(),"gratzinguild")) then
            -- 
            --msg = strreplace(msg, "gratzinguild", "")
            -- 
            print(strlen(msg));
            --print (msg);
            -- print (var[2].. " " ..var[3])
            delete, newmsg = strsplit(" ", msg, 2)
            --print (kim.. " kim");
            --print (mie.. " mie");
            --print(delete);
            --print(newmsg);
            if (newmsg == nil) then
                print("nil");
            elseif (newmsg == "") then
                print("Tom");
            else
                print("Andet: " ..newmsg);
            end
        -- ******************** ********************
        -- Is gratzingroup in the string ?
        elseif (string.find(msg:lower(),"gratzingroup")) then
            -- 
            msg = strreplace(msg, "gratzingroup", "")
            -- 
            -- GS_GratzInGroup = msg
            print (msg);
        end
    ]]end


-- GS_Delay
-- GS_Break
-- GS_GratzInGuild
-- GS_GratzInGroup
-- GS_WelcomeOnNew
-- GS_RaidWarningOnNewInGuild

end

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ********************** * * * * * OnEvent * * * * * ********************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

-- Event handler
f:SetScript("OnEvent", function(self, event, arg1, arg2, agr3, ...)
    -- Find out of what event it is
    if (event == "ADDON_LOADED") then
        if (arg1:lower() == "guildslacker") then
            print(GS_LOAD1 .. GS_Version .. GS_LOAD2);
            -- print("Type /GuildSlacker or /GSL for more help.");
            f:UnregisterEvent("ADDON_LOADED");
        else
            return
        end
-- ************************* * * * * * * * * * * *************************
    elseif (event == "CHAT_MSG_GUILD_ACHIEVEMENT") then
        -- Get the name of the one there got the achievement
        GS_GuildAchievementBy = arg2;
        -- Make sure that it's not our self
        if (GS_PlayerName ~= GS_GuildAchievementBy) then
            GS_WhatEvent = "Achievement";
            GS_TimeDelay = GetTime();
            GS_RandomDelay = math.random(1, 5)
            GS_Loop = "Go";
        end
-- ************************* * * * * * * * * * * *************************
    elseif (event == "CHAT_MSG_ACHIEVEMENT") then
        -- Get the name of the one there got the achievement
        GS_AchievementBy = arg2;
        -- Make sure thats not our self
        if (GS_PlayerName ~= GS_AchievementBy) then
            -- Are we in a raid or a party ?
            if (GetNumGroupMembers() > 0) or (GetNumSubgroupMembers() > 0) then
                -- Is the player in our raid or party ?
                if (UnitInRaid(GS_AchievementBy) ~= nil) or (UnitInParty(GS_AchievementBy) ~= nil) then
                    GS_WhatEvent = "PartyAndRaid";
                    GS_TimeDelay = GetTime();
                    GS_RandomDelay = math.random(1, 5)
                    GS_Loop = "Go";
                end
            end
        else
            -- It is our self so we don't say anything just do other stuf
            if (GS_PlayerName == GS_AchievementBy) then
                -- Are we alowed to take a picture ?
                if (GS_PicOnAchievement == "on") then
                    GS_PicDelay = GetTime();
                    GS_TakePic = "Go";
                end
            end
        end
-- ************************* * * * * * * * * * * *************************
    elseif (event == "CHAT_MSG_SYSTEM") then
        if(string.find(arg1,"has joined the guild.")) then
            -- Get the name of the one there is joining the guild
            var = {strsplit(" ", arg1)}
            -- Check that it's not our self
            if (GS_PlayerName ~= var[1]) then
                GS_WhatEvent = "JoinGuild";
                GS_TimeDelay = GetTime();
                GS_RandomDelay = math.random(1, 5)
                GS_NameJoinGuild = var[1];
                GS_Loop = "Go";
            end
        end
-- ************************* * * * * * * * * * * *************************
    elseif (event == "PLAYER_LEVEL_UP") then
        GS_TimeDingDelay = GetTime();
        GS_NewLevel = arg1;
        GS_GetDingDelay = "go";
-- ************************* * * * * * * * * * * *************************
    elseif (event == "CHAT_MSG_TEXT_EMOTE") then
        return
-- ************************* * * * * * * * * * * *************************
    elseif (event == "PLAYER_LOGOUT") then
        return
-- ************************* * * * * * * * * * * *************************
    elseif (event == "CHAT_MSG_WHISPER") then
        GS_TimeDelay = GetTime();
        GS_DoWhisper(arg1, arg2);
-- ************************* * * * * * * * * * * *************************
    elseif (event == "CHAT_MSG_BN_WHISPER") then
        GS_TimeDelay = GetTime();
        GS_DoWhisper(arg1, arg2);
    end
end)

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ********************* * * * * * OnUpdate * * * * * ********************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

-- Run on every update and here we do all the checks
f:SetScript("OnUpdate", function(self, elapsed)
    -- Just a doubble check
    if (GS_PlayerName == nil) or (GS_LastMessage == nil) or (GS_TimeDelay == nil) or (GS_OldDate == nil) or (GS_RandomDelay == nil) or (GS_TakePic == nil) or (GS_PicDelay == nil) or (GS_TimeDingDelay == nil) or (GS_GetDingDelay == nil) then
        GS_PlayerName = UnitName("player");
        GS_LastMessage = GetTime();
        GS_TimeDelay = GetTime();
        GS_OldDate = CalendarGetDate();
        GS_RandomDelay = 1;
        GS_TakePic = "Off";
        GS_PicDelay = GetTime();
        GS_TimeDingDelay = GetTime();
        GS_WhatEvent = "Nothing";
        GS_Loop = "Stop";
        GS_GetDingDelay = "Stop";
    end
    -- Take a picture if we are allowed
    if (GS_TakePic == "Go") then
        -- Wait 1.2 sec before we take picture
        if ((GetTime() - GS_PicDelay) > 1.2) then
            Screenshot();
            GS_TakePic = "Off";
            print ("|cffFFFF00"..GS_SCREENSHOT.."|r");
        end
    end
    -- Ding delay
    if (GS_GetDingDelay:lower() == "go") then
        if ((GetTime() - GS_TimeDingDelay) > GS_DingDelay) then
            GS_GetDingDelay = "Stop"
            GS_Level(GS_NewLevel);
        end
    end
    -- Are we allowed to do this loop ?
    if (GS_Loop == "Go") then
        -- Check that the player is the player
        if (UnitName("player") == nil) then
            return;
        end
        -- Check date so that we don't get errors after midnight
        if GS_OldDate == nil then
            GS_OldDate = CalendarGetDate();
            GS_LastMessage = (GetTime() - 10);
        elseif GS_OldDate ~= CalendarGetDate() then
            GS_OldDate = CalendarGetDate();
            GS_LastMessage = (GetTime() - 10);
        end
        -- Don't do anything if we are AFK
        if (not UnitIsAFK("player")) then
            -- Make sure that we don't spam the chat
            if ((GetTime() - GS_LastMessage) > GS_Break) then
                -- Make sure that there is a small delay before we say anything in chat
                if ((GetTime() - GS_TimeDelay) > (GS_Delay + GS_RandomDelay)) then
                    -- All was ok, now we just have to send to the right function
                    if GS_WhatEvent == "Achievement" then
                        GS_DoAchievement()
                    elseif GS_WhatEvent == "PartyAndRaid" then
                        GS_DoPartyAndRaid()
                    elseif GS_WhatEvent == "JoinGuild" then
                        GS_DoJoinGuild()
                    else
                        print (GS_ERROR1);
                        print (GS_ERROR2);
                        print (GS_ERROR3 .. GS_Version);
                        print (GS_ERROR4.. "000001");
                    end
                    -- Stop the loop
                    GS_Loop = "Stop";
                end
            -- It is to fast to say anything now
            else
                -- Stop the loop
                GS_Loop = "Stop";
            end
        -- Player is AFK
        else
            -- Stop the loop
            GS_Loop = "Stop";
        end
    end
end)

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- *************** * * * * * Do guild achievement * * * * * **************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

function GS_DoAchievement()
    if (GS_GratzInGuild:lower() == "on") then
        GS_Random = math.random(1, 15)
        if (GS_Random == 1) then
            SendChatMessage(GS_GRATZ1, "GUILD");
        elseif (GS_Random == 2) then
            SendChatMessage(GS_GRATZ2, "GUILD");
        elseif (GS_Random == 3) then
            SendChatMessage(GS_GRATZ3, "GUILD");
        elseif (GS_Random == 4) then
            SendChatMessage(GS_GRATZ4, "GUILD");
        elseif (GS_Random == 5) then
            SendChatMessage(GS_GRATZ5, "GUILD");
        elseif (GS_Random == 6) then
            SendChatMessage(GS_GRATZ6, "GUILD");
        elseif (GS_Random == 7) then
            SendChatMessage(GS_GRATZ7, "GUILD");
        elseif (GS_Random == 8) then
            SendChatMessage(GS_GRATZ8, "GUILD");
        elseif (GS_Random == 9) then
            SendChatMessage(GS_GRATZ9, "GUILD");
        elseif (GS_Random == 10) then
            SendChatMessage(GS_GRATZ10, "GUILD");
        elseif (GS_Random == 11) then
            SendChatMessage(GS_GRATZ11, "GUILD");
        elseif (GS_Random == 12) then
            SendChatMessage(GS_GRATZ12, "GUILD");
        elseif (GS_Random == 13) then
            SendChatMessage(GS_GRATZ13, "GUILD");
        elseif (GS_Random == 14) then
            SendChatMessage(GS_GRATZ14, "GUILD");
        elseif (GS_Random == 15) then
            SendChatMessage(GS_GRATZ15, "GUILD");
        else
            print (GS_ERROR1);
            print (GS_ERROR2);
            print (GS_ERROR3 .. GS_Version);
            print (GS_ERROR4.. "000002");
        end
        GS_LastMessage = GetTime();
        GS_Random = nil
    end
end

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ************ * * * * * Do raid / party achievement * * * * * **********
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

function GS_DoPartyAndRaid()
    if (GS_GratzInGroup:lower() == "on") then
        -- Are we in raid or party ?
        if (GetNumGroupMembers() > 0) then
            GS_GratzWhere = "RAID"
        elseif (GetNumSubgroupMembers() > 0) then
            GS_GratzWhere = "PARTY"
        else
            print (GS_ERROR1);
            print (GS_ERROR2);
            print (GS_ERROR3 .. GS_Version);
            print (GS_ERROR4.. "000003");
        end
        -- Make a random number and do the gratz
        GS_Random = math.random(1, 15)
        if (GS_Random == 1) then
            SendChatMessage(GS_GRATZ1, GS_GratzWhere);
        elseif (GS_Random == 2) then
            SendChatMessage(GS_GRATZ2, GS_GratzWhere);
        elseif (GS_Random == 3) then
            SendChatMessage(GS_GRATZ3, GS_GratzWhere);
        elseif (GS_Random == 4) then
            SendChatMessage(GS_GRATZ4, GS_GratzWhere);
        elseif (GS_Random == 5) then
            SendChatMessage(GS_GRATZ5, GS_GratzWhere);
        elseif (GS_Random == 6) then
            SendChatMessage(GS_GRATZ6, GS_GratzWhere);
        elseif (GS_Random == 7) then
            SendChatMessage(GS_GRATZ7, GS_GratzWhere);
        elseif (GS_Random == 8) then
            SendChatMessage(GS_GRATZ8, GS_GratzWhere);
        elseif (GS_Random == 9) then
            SendChatMessage(GS_GRATZ9, GS_GratzWhere);
        elseif (GS_Random == 10) then
            SendChatMessage(GS_GRATZ10, GS_GratzWhere);
        elseif (GS_Random == 11) then
            SendChatMessage(GS_GRATZ11, GS_GratzWhere);
        elseif (GS_Random == 12) then
            SendChatMessage(GS_GRATZ12, GS_GratzWhere);
        elseif (GS_Random == 13) then
            SendChatMessage(GS_GRATZ13, GS_GratzWhere);
        elseif (GS_Random == 14) then
            SendChatMessage(GS_GRATZ14, GS_GratzWhere);
        elseif (GS_Random == 15) then
            SendChatMessage(GS_GRATZ15, GS_GratzWhere);
        else
            print (GS_ERROR1);
            print (GS_ERROR2);
            print (GS_ERROR3 .. GS_Version);
            print (GS_ERROR4.. "000004");
        end
        -- Reset so we don't get errors next time
        GS_LastMessage = GetTime();
        GS_Random = nil
    end
end

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ******************* * * * * * Do join guild * * * * * *****************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

function GS_DoJoinGuild()
    if (GS_WelcomeOnNew:lower() == "on") then
        GS_Random = math.random(1, 10)
        if (GS_Random == 1) then
            SendChatMessage(GS_WELCOME1, "GUILD");
        elseif (GS_Random == 2) then
            SendChatMessage(GS_WELCOME2, "GUILD");
        elseif (GS_Random == 3) then
            SendChatMessage(GS_WELCOME3, "GUILD");
        elseif (GS_Random == 4) then
            SendChatMessage(GS_WELCOME4, "GUILD");
        elseif (GS_Random == 5) then
            SendChatMessage(GS_WELCOME5, "GUILD");
        elseif (GS_Random == 6) then
            SendChatMessage(GS_WELCOME6 .. GS_NameJoinGuild, "GUILD");
        elseif (GS_Random == 7) then
            SendChatMessage(GS_WELCOME7 .. GS_NameJoinGuild, "GUILD");
        elseif (GS_Random == 8) then
            SendChatMessage(GS_WELCOME8 .. GS_NameJoinGuild, "GUILD");
        elseif (GS_Random == 9) then
            SendChatMessage(GS_WELCOME9 .. GS_NameJoinGuild, "GUILD");
        elseif (GS_Random == 10) then
            SendChatMessage(GS_WELCOME10 .. GS_NameJoinGuild, "GUILD");
        else
            print (GS_ERROR1);
            print (GS_ERROR2);
            print (GS_ERROR3 .. GS_Version);
            print (GS_ERROR4.. "000005");
        end
        GS_LastMessage = GetTime();
        GS_Random = nil
        GS_NameJoinGuild = nil
    end

    if (GS_RaidWarningOnNewInGuild:lower() == "on") then
        RaidNotice_AddMessage(RaidBossEmoteFrame, "A new member have joind the guild.", ChatTypeInfo["RAID_WARNING"])
    end
end

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ********************* * * * * * Level Up * * * * * ********************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

function GS_Level(GS_NewLevel)
    -- Do we say ding in guild chat ?
    if (GS_DingOnLevel:lower() == "on") then
        -- Wait with the ding so we don't sound like a robot
	    if (GS_NewLevel == 10) then
            SendChatMessage(GS_DING10 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 20) then
            SendChatMessage(GS_DING20 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 30) then
            SendChatMessage(GS_DING30 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 40) then
            SendChatMessage(GS_DING40 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 50) then
            SendChatMessage(GS_DING50 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 60) then
            SendChatMessage(GS_DING60 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 70) then
            SendChatMessage(GS_DING70 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 80) then
            SendChatMessage(GS_DING80 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 85) then
            SendChatMessage(GS_DING85 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 90) then
            SendChatMessage(GS_DING90 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 95) then
            SendChatMessage(GS_DING95 .. GS_NewLevel, "GUILD");
        elseif (GS_NewLevel == 100) then
            SendChatMessage(GS_DING100 .. GS_NewLevel, "GUILD");
        else
            SendChatMessage(GS_DING_OTHER .. GS_NewLevel, "GUILD");
        end
        -- Do we take a Picture when we ding ?
        if (GS_PicOnLevel == "on") then
            -- Make a note in chat so we on Picture can see what level we gain
            -- print ("You are now level " ..GS_NewLevel.. ", Good job...");
            -- print ("The "..date.." you gained level "..GS_NewLevel);
            GS_TakePic = "Go";
        end
    end
    -- Reset level so we dont use it next time
    GS_NewLevel = nil
end

-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************
-- ******************** * * * * * Do whisper * * * * * *******************
-- ************************* * * * * * * * * * * *************************
-- ************************* * * * * * * * * * * *************************

function GS_DoWhisper(arg1, arg2)
    -- Are we alowed to do a whisper ?
    if (GS_DoTheWhisper == "on") then
        RaidNotice_AddMessage(RaidBossEmoteFrame, "[Whisper from:] ["..arg2.."]", ChatTypeInfo["RAID_WARNING"])
        RaidNotice_AddMessage(RaidBossEmoteFrame, arg1, ChatTypeInfo["RAID_WARNING"])
    end
end
